// 等待DOM加载完成
document.addEventListener('DOMContentLoaded', function() {
    // 获取密码输入框和切换按钮
    const passwordInput = document.getElementById('password');
    const togglePasswordBtn = document.getElementById('toggle-password');
    const passwordIcon = togglePasswordBtn.querySelector('i');
    
    // 添加密码可见性切换功能
    togglePasswordBtn.addEventListener('click', function() {
        // 切换密码输入框的类型
        const type = passwordInput.getAttribute('type') === 'password' ? 'text' : 'password';
        passwordInput.setAttribute('type', type);
        
        // 切换图标
        if (type === 'password') {
            passwordIcon.classList.remove('fa-eye');
            passwordIcon.classList.add('fa-eye-slash');
        } else {
            passwordIcon.classList.remove('fa-eye-slash');
            passwordIcon.classList.add('fa-eye');
        }
    });
    
    // 表单提交时确保密码字段是密码类型
    const loginForm = document.querySelector('form');
    if (loginForm) {
        loginForm.addEventListener('submit', function() {
            passwordInput.setAttribute('type', 'password');
            passwordIcon.classList.remove('fa-eye');
            passwordIcon.classList.add('fa-eye-slash');
        });
    }
});